//
//  MainOneCollectionReusableView.m
//  KaKaWallet
//
//  Created by admin on 2016/10/26.
//  Copyright © 2016年 ibendi. All rights reserved.
//

#import "MainOneCollectionReusableView.h"
#import <SDCycleScrollView/SDCycleScrollView.h>

@implementation MainOneCollectionReusableView

- (id)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        
        UIView *hbkView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, [UIScreen mainScreen].bounds.size.width, 370)];
        hbkView.backgroundColor = UIColorHex(0xf2f2f2);
        [self addSubview:hbkView];
        
        _cycleScrollView = [SDCycleScrollView cycleScrollViewWithFrame:CGRectMake(0, 0, [UIScreen mainScreen].bounds.size.width, 160) delegate:self placeholderImage:[UIImage imageNamed:@"img_logo_defaultimage"]];
        _cycleScrollView.delegate = self;
        _cycleScrollView.pageControlStyle = SDCycleScrollViewPageContolStyleClassic;
        [hbkView addSubview:_cycleScrollView];
        _cycleScrollView.backgroundColor = [UIColor whiteColor];
        _cycleScrollView.scrollDirection = UICollectionViewScrollDirectionHorizontal;
        _cycleScrollView.currentPageDotColor = UIColorHex(0x2cbb64);
        _cycleScrollView.localizationImageNamesGroup = @[@"icon-address list-press@3x",@"icon-address list-press@3x",@"icon-address list-press@3x"];
        
        
        _cycleScrollView.clickItemOperationBlock = ^(NSInteger currentIndex){
           
        };
        
        UIView *topVIew = [[UIView alloc] initWithFrame:CGRectMake(0, _cycleScrollView.endPointY +10, [UIScreen mainScreen].bounds.size.width, 45)];
        [hbkView addSubview:topVIew];
        topVIew.backgroundColor = [UIColor whiteColor];
        
        UIImageView *imgOne = [[UIImageView alloc] initWithFrame:CGRectMake(12, 10, 25, 25)];
        imgOne.backgroundColor = [UIColor redColor];
        [topVIew addSubview:imgOne];
        
        UILabel *titleLbl = [[UILabel alloc] initWithFrame:CGRectMake(imgOne.endPointX+10, 10, 100, 25)];
        titleLbl.text = @"热门推荐";
        titleLbl.textColor = UIColorHex(0x33333);
        titleLbl.font = [UIFont systemFontOfSize:16.0];
        [topVIew addSubview:titleLbl];
        
        //    ========================================
        UIButton *kkBtnOne = [UIButton buttonWithType:UIButtonTypeCustom];
        kkBtnOne.frame = CGRectMake(0, topVIew.endPointY+10, 143, 131);
        [hbkView addSubview:kkBtnOne];
        kkBtnOne.backgroundColor = [UIColor whiteColor];
        
        UIImageView *kkImgOne = [[UIImageView alloc] init];
        [kkBtnOne addSubview:kkImgOne];
        [kkImgOne mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.mas_equalTo(kkBtnOne.top).mas_equalTo(20);
            make.centerX.mas_equalTo(kkBtnOne);
            make.size.mas_equalTo(CGSizeMake(60, 60));
        }];
        kkImgOne.backgroundColor = [UIColor yellowColor];
        
        UILabel *kkLblOne = [UILabel new];
        [kkBtnOne addSubview:kkLblOne];
        kkLblOne.text = @"精致下午茶";
        kkLblOne.font = [UIFont systemFontOfSize:14];
        kkLblOne.textColor = UIColorHex(0x333333);
        kkLblOne.textAlignment = NSTextAlignmentCenter;
        [kkLblOne mas_makeConstraints:^(MASConstraintMaker *make) {
            make.bottom.mas_equalTo(kkBtnOne.bottom).offset(-20);
            make.left.and.right.mas_equalTo(kkBtnOne).offset(0);
            make.height.mas_equalTo(25);
        }];
        
        //    =================================
        
        UIButton *kkBtnTwo = [UIButton buttonWithType:UIButtonTypeCustom];
        [hbkView addSubview:kkBtnTwo];
        kkBtnTwo.frame = CGRectMake(kkBtnOne.endPointX+1, topVIew.endPointY+10, [UIScreen mainScreen].bounds.size.width-144, 65);
        kkBtnTwo.backgroundColor = [UIColor whiteColor];
        
        UIImageView *kkImgTwo = [[UIImageView alloc] init];
        [kkBtnTwo addSubview:kkImgTwo];
        kkImgTwo.backgroundColor = [UIColor redColor];
        [kkImgTwo mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.mas_equalTo(kkBtnTwo.mas_left).offset(40);
            make.centerY.mas_equalTo(kkBtnTwo);
            make.size.mas_equalTo(CGSizeMake(40, 40));
        }];
        
        UILabel *kkLblTwo = [UILabel new];
        [kkBtnTwo addSubview:kkLblTwo];
        kkLblTwo.textAlignment = NSTextAlignmentLeft;
        kkLblTwo.text = @"特色套餐版";
        kkLblTwo.font = [UIFont systemFontOfSize:14];
        kkLblTwo.textColor = UIColorHex(0x333333);
        [kkLblTwo mas_makeConstraints:^(MASConstraintMaker *make) {
            make.centerY.mas_equalTo(kkBtnTwo);
            make.left.mas_equalTo(kkImgTwo.mas_right).offset(20);
            make.size.mas_equalTo(CGSizeMake(100, 25));
        }];
        
        //    =================================
        
        UIButton *kkBtnThree = [UIButton buttonWithType:UIButtonTypeCustom];
        [hbkView addSubview:kkBtnThree];
        kkBtnThree.frame = CGRectMake(kkBtnOne.endPointX+1, kkBtnTwo.endPointY+1, [UIScreen mainScreen].bounds.size.width-144, 65);
        kkBtnThree.backgroundColor = [UIColor whiteColor];
        
        UIImageView *kkImgThree = [[UIImageView alloc] init];
        [kkBtnThree addSubview:kkImgThree];
        kkImgThree.backgroundColor = [UIColor redColor];
        [kkImgThree mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.mas_equalTo(kkBtnThree.mas_left).offset(40);
            make.centerY.mas_equalTo(kkBtnThree);
            make.size.mas_equalTo(CGSizeMake(40, 40));
        }];
        
        UILabel *kkLblThree = [UILabel new];
        [kkBtnThree addSubview:kkLblThree];
        kkLblThree.textAlignment = NSTextAlignmentLeft;
        kkLblThree.text = @"创意私房菜";
        kkLblThree.font = [UIFont systemFontOfSize:14];
        kkLblThree.textColor = UIColorHex(0x333333);
        [kkLblThree mas_makeConstraints:^(MASConstraintMaker *make) {
            make.centerY.mas_equalTo(kkBtnThree);
            make.left.mas_equalTo(kkImgThree.mas_right).offset(20);
            make.size.mas_equalTo(CGSizeMake(100, 25));
        }];
        
        kkBtnOne.tag = 200;
        kkBtnTwo.tag = 201;
        kkBtnThree.tag = 202;
        [kkBtnOne addTarget:self action:@selector(mainBtnAcction:) forControlEvents:UIControlEventTouchUpInside];
        [kkBtnTwo addTarget:self action:@selector(mainBtnAcction:) forControlEvents:UIControlEventTouchUpInside];
        [kkBtnThree addTarget:self action:@selector(mainBtnAcction:) forControlEvents:UIControlEventTouchUpInside];
    }
    return self;
}


-(void)mainBtnAcction:(UIButton *)sender
{
    if (self.kkCollectionAction) {
        self.kkCollectionAction(sender.tag);
    }
}


@end
